#!/bin/bash

# watch -n.3 'bash printInterrupts.sh "1 2 3 4 5 6 7"'

# Parse command-line arguments
if [ $# -ne 1 ]; then
    echo "Usage: $0 <core_list>"
    exit 1
fi

core_list=$1

# Header for output
printf "%-4s" "Core"
for core in $core_list
do
    printf "%10s" "$core"
done
printf "\n"


# Loop over each interrupt and get the counts for the specified cores
interrupts=("TLB" "CAL" "LOC")
for interrupt in "${interrupts[@]}"
do
    printf "%-4s" "$interrupt"
    line=$(cat /proc/interrupts | grep "$interrupt")
    read -ra items <<< "$line"
    for core in $core_list
    do  
        printf "%10s" "${items[$core+1]}"
    done
    printf "\n"
done

